package de.bazinga.rotw.network.message;

import com.captiveimagination.jgn.message.Message;
import com.captiveimagination.jgn.message.type.CertifiedMessage;
import com.captiveimagination.jgn.message.type.PlayerMessage;
import com.captiveimagination.jgn.message.type.TimestampedMessage;

import de.bazinga.rotw.game.RotwGameState;
import de.bazinga.rotw.person.OpponentList;

public class FallDamageMessage extends Message implements CertifiedMessage, PlayerMessage, TimestampedMessage, GameMessage {
	private float distance = 0;

	public float getDistance() {
		return distance;
	}

	public void setDistance(float distance) {
		this.distance = distance;
	}
	

	public void handleMessage(RotwGameState game, Message msg, boolean server) {
		if(!(msg instanceof FallDamageMessage)) return ;

		// Player touched a item
		FallDamageMessage message = (FallDamageMessage)msg;
		
		if(server) {
			OpponentList.getInstance().getOpponent(message.getPlayerId()).fallDamage(
					message.getDistance());
		}
	}
}